//
// Created by hunan on 2025/10/1.
//

#ifndef OPEN_NET_HLS_FRAGMENT_H
#define OPEN_NET_HLS_FRAGMENT_H

#include <map>
#include <string>

class HlsM3U8Message;
class HlsFragment
{
    enum EmFragmentStatus
    {
        EmInit,
        EmUsed,
        EmDone,
        EmFailed,
    };
    struct Fragment
    {
        int m_status;   // EmFragmentStatus
        int m_index{-1};// index map uri vector
    };
public:
    explicit HlsFragment(HlsM3U8Message * message);
    std::string GetOneFragment(int & index);
    void UpdateFragmentSuccess(int index);
    void UpdateFragmentFailed(int index);
    int  AllFragmentSuccess() const;
private:
    void FragmentHlsMessage();
private:
    HlsM3U8Message * m_message;
    std::map<int, Fragment> m_fragments;
};

#endif // OPEN_NET_HLS_FRAGMENT_H
